# 返回偶数的迭代器
class EvenIterators(object):
    def __init__(self, n):
        self.stop = n
        self.value = -2

    def __iter__(self):
        return self

    def next(self):
        if self.value + 2 > self.stop:
            raise StopIteration
        self.value += 2
        return self.value


def fix(x):
    return x * x


if __name__ == '__main__':
    even_iter = EvenIterators(5)
    # print(even_iter.next())
    # print(even_iter.next())
    # print(even_iter.next())
    # print(even_iter.next())  # 报 StopIteration
    print(list(map(fix,even_iter)))
